package gui.menu;

import gui.CanvasManager;
import gui.screens.HighscoreScreen;
import gui.screens.HunterInfoScreen;
import gui.screens.RBCanvas;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

import application.MainController;

/**
 * Class for the menu that is shown during the game.
 * @author Sandra Mayer
 *
 */
public class GameMenu implements CommandListener {
	
	private Command exitCmd;
	private Command refreshCmd;
	private Command infoCmd;
	private Command highscoreCmd;
	
	private RBCanvas canvas;
	
	/**
	 * Constructor.
	 * @param can RBCanvas
	 */
	public GameMenu(RBCanvas can) {
		canvas = can;
		exitCmd = new Command("Exit", Command.ITEM, 0);
		refreshCmd = new Command("Refresh", Command.ITEM, 0);
		infoCmd = new Command("Info", Command.ITEM, 0);
		highscoreCmd = new Command("Highscore", Command.ITEM, 0);
		
		canvas.addCommand(infoCmd);
		canvas.addCommand(refreshCmd);
		canvas.addCommand(highscoreCmd);
		canvas.addCommand(exitCmd);
	}

	/**
	 * Does the command action.
	 */
	public void commandAction(Command cmd, Displayable arg1) {
		if (cmd == exitCmd) {
			CanvasManager.showExitScreen();
		} else if (cmd == refreshCmd) {
			MainController.getInstance().updateField();
		} else if (cmd == infoCmd) {
			CanvasManager.setCurrent(HunterInfoScreen.getInstance());
		} else if (cmd == highscoreCmd) {
			CanvasManager.setCurrent(HighscoreScreen.getInstance());
		}
	}
}
